11. Run Turtlesim
Run Turtlesim
Run Turtlesim
Now that you’ve added ROS’ environment variables to your terminal session, you can run the turtlesim package!
Starting the Master process
Before you can run any ROS nodes, you must start the Master process.
The Master process is responsible for the following (and more):
- Providing naming and registration services to other running nodes
- Tracking all publishers and subscribers
- Aggregating log messages generated by the nodes
- Facilitating connections between nodes
To run the master process, execute the command
sh
roscore
If all goes well (and it should), you will see output similar to this:
This indicates that ROS Master is running! To terminate the ROS Master process, you can simply send the SIGINT signal to the process by pressing ctrl-c in the roscore terminal window.
We are now ready to begin launching nodes!
Running Turtlesim Nodes
Now that the ROS Master is running, we can run our first two ROS nodes.
To do so, we will execute the
rosrun
command in a new terminal window, passing as parameters the name of the package we wish to run, and the name of the actual node.
Note
You can open a second instance of you current terminal using
CTRL + SHIFT + T
.
Tab completion is your friend. Each ROS distribution comes with a staggering number of packages, and an even more staggering number of nodes. In the bash shell, a single-tap of the tab key will autocomplete the command, if there is a single match. A double-tap of the tab key will result in a list of all possible matches, in the case that a single match cannot be found.
First we will start the
turtlesim_node
, in the
turtlesim
package using the following command in a second terminal instance.
$ rosrun turtlesim turtlesim_node
Next, we will start the
turtle_teleop_key node
, also from the
turtlesim
package in a third terminal instance.
$ rosrun turtlesim turtle_teleop_key
By using the arrow keys with the
turtle_teleop_key
node’s console selected, we are able to move the turtle in turtlesim!